package com.itstack.springframework.beans.beans;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
 * ClassName:
 * Description: TODO
 *
 * @author: Guo Shuai
 * @version: 1.0
 * @Date: 2021\11\24 0024
 */
public class BeanFactory {

    private Map<String, Object> beanMap = new ConcurrentHashMap<>();

    public Object getBean(String name) {
        return beanMap.get(name);
    }

    public void registerBeanDefinition(String name, BeanDefinition beanDefinition) {
        try {
            beanMap.put(name, beanDefinition.getType().newInstance());
        } catch (InstantiationException | IllegalAccessException e) {
            e.printStackTrace();
        }
    }
}
